package org.dt.common.sequence.spring;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;

/**
 * <p>creation time: 2019/01/21 22:07</p>
 *
 * @author yujiadong
 **/
@Configuration
public class SeqManagerInitializationConfiguration implements ImportSelector {
    @SuppressWarnings("unchecked")
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        Map<String, Object>                          attributes    = importingClassMetadata.getAnnotationAttributes(EnableSequenceManager.class.getName(), false);
        Class<? extends BaseSeqManagerConfiguration> configuration = (Class<? extends BaseSeqManagerConfiguration>) attributes.get("configuration");
        return new String[]{configuration.getName()};
    }
}
